{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "%matplotlib inline\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "import pymongo"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "host = '101.200.59.101'\n",
    "\n",
    "\n",
    "def get_database_connect():\n",
    "    mc = pymongo.MongoClient(host=host, port=27017)\n",
    "    try:\n",
    "        db = mc.sqlData\n",
    "        db.authenticate('dsg', 'dsg@2017')\n",
    "        return db\n",
    "    finally:\n",
    "        mc.close()\n",
    "\n",
    "\n",
    "db = get_database_connect()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "ret = list(db.XWFX.find({'newsPublishTime':{'$gte':'2017-11-17'}},{'_id':0}).sort('newsPublishTime',-1))\n",
    "df = pd.DataFrame(ret).set_index('newsPublishTime')\n",
    "df.iloc[:,1:6]\n",
    "df.plot();"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
